#include "threadpool.hpp"
#include "Task.hpp"
#include <ctime>

using namespace std;

const string opers = "+-*/%";

int main()
{
    srand(time(nullptr) ^ getpid());
    //ThreadPool<int> *tp = new ThreadPool<int>();
    //ThreadPool<Task> *tp = new ThreadPool<Task>();
    ThreadPool<Task> *tp = ThreadPool<Task>::GetInstance();

    ThreadPool<Task>::GetInstance()->strat();

    while (true)
    {
        // int data = rand() % 100;
        int a = rand() % 10 + 1;
        int b = rand() % 10;
        char op = opers[rand() % opers.size()];
        Task t(a,b,op);
        t.run();

        ThreadPool<Task>::GetInstance()->push(t);
        cout << "生产了一个任务: " << t.display() << endl;

        usleep(10);
    }

    return 0;
}